#include <iostream>
using namespace std;
void InputMatrix(int d1, int d2, int* matrix)
{
    for (int i = 0; i < d1 * d2; i++)
    {
        cin >> matrix[i];
    }
}
void OutputMatrix(int d1, int d2, int* matrix)
{
    cout << "The original matrix you input is:" << endl;
    for (int i = 0; i < d1 * d2; i++)
    {
        cout << matrix[i] << "    ";
        if ((i + 1) % d1 == 0)
            cout << endl;
    }
}
void MultiplyMatrix(int d1, int d2, int* matrix)
{
    int number;
    cout << "Please input the number that will multiply the matrix: ";
    cin >> number;
    for (int i = 0; i < d1 * d2; i++)
    {
        cout << matrix[i] * number << "    ";
        if ((i + 1) % d1 == 0)
            cout << endl;
    }
}
int main()
{
    int d1, d2;
    int* matrix;
    matrix = new int[100];
    cout << "Please input two dimensions of the matrix: ";
    cin >> d1 >> d2;
    InputMatrix(d1, d2, matrix);
    cout << "---------------------------------------------------------" << endl;
    OutputMatrix(d1, d2, matrix);
    char flag = 'y';
    while (tolower(flag) == 'y') {
        cout << "---------------------------------------------------------" << endl;
        MultiplyMatrix(d1, d2, matrix);
        cout << "Do you want to continue to multiply the matrix?(Y/N)";
        cin >> flag;
    }
    delete[]matrix;
}